package com.lbd.system.dao;

import com.lbd.system.bean.EventLog;
import com.lbd.system.bean.User;
import com.lbd.system.bean.User;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.web.PageableDefault;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * Created by WangYajie on 2016/9/12.
 */
public interface UserRepository extends PagingAndSortingRepository<User, Serializable>, JpaSpecificationExecutor<User> {
    @Modifying
    @Query("update  com.lbd.system.bean.User set state=2,lastDisableDate=:date where id = :id ")
    void disableUser(@Param("id") String id, @Param("date") Date date);


    @Modifying
    @Query("update  com.lbd.system.bean.User set  password=:password where id = :id ")
    void restPassword(@Param("id") String id, @Param("password") String password);

    @Modifying
    @Query("update  com.lbd.system.bean.User set state=1  where id = :id ")
    void enableUser(@Param("id") String id);

    @Modifying
    @Query("update  com.lbd.system.bean.User set type=:type  where id = :id ")
    void updateTypeById(@Param("id") String id, @Param("type") int type);

    User findByTelephone(String telephone);
}
